import { CurvedEdge, CurvedEdgeModel } from './CurvedEdge'

class CustomEdge extends CurvedEdge {
}

class CustomEdgeModel extends CurvedEdgeModel {
    initEdgeData(data: any) {
        data.properties = {            
            customNodeName: '同意',
            customNodeTypeName: '连线',
            customNodeColor: 'rgb(130, 179, 102)',            
        }
        super.initEdgeData(data)
        this.radius = 5                
    }
    // customTextPosition = true;
    getTextStyle() {
        const style = super.getTextStyle();
        // const { x: x1 } = this.pointsList[0];
        // const { x: x2 } = this.pointsList[1];
        // if (x1 === x2) {
        // 垂直
        //   style.textWidth = 20;
        // } else {
        //   style.textWidth = 200;
        // }
        style.color = 'var(--el-text-color-primary)';
        style.fontSize = 14;
        style.className = 'custom-text';
        return style;
    }
    getEdgeStyle() {
        const style = super.getEdgeStyle()
        style.strokeWidth = 2.5
        style.stroke = 'rgb(130, 179, 102)'
        return style
    }
    setAttributes() {
        this.isAnimation = false
    }

    getEdgeAnimationStyle() {
        const style = super.getEdgeAnimationStyle()
        style.strokeDasharray = '15 5'
        style.animationDuration = '10s'
        style.stroke = 'rgb(130, 179, 102)'
        return style
    }
}

export default {
    type: 'custom-edge',
    model: CustomEdgeModel,
    view: CustomEdge,
};